package function

import (
	"GraduationProject/public/models"
	"GraduationProject/public/params"
	"GraduationProject/worker/fengchedm/fetcher/normal"
	"GraduationProject/worker/fengchedm/parser"
	"GraduationProject/worker/worker_tools"
	"fmt"
)

func Category(seed models.Record) (result params.Result) {
	content, err := normal.Get(seed.Url)
	if err != nil {
		seed.Error = err.Error()
		return params.Result{
			Result: []models.Record{seed},
		}
	}

	//fmt.Println("category content:", string(content))

	result.Seeds, result.Result = parser.Category(seed, content)
	fmt.Println("category result:", result)

	if !visited {
		worker_tools.Visited(seed)
	}

	return result
}
